package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.BasePageInfo;
import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.bean.MarketCollect;
import com.cskaoyan.bean.param.CommonData;
import com.cskaoyan.service.admin.MarketCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LC_RSH
 * @date 2022/6/26 11:00
 */
@RestController
@RequestMapping("admin/collect")
public class AdminCollectController {
    @Autowired
    MarketCollectService marketCollectService;

    /**
     * 通过用户id和商品id展示收藏
     * 判断id参数是否有效
     * @param /userId valueId
     * @return
     * @author LC_R-SH
     * @since 2022/06/26 11:09
     */
    @RequestMapping("list")
    public BaseRespVo list(String userId, String valueId, BasePageInfo info) {
        Integer id = 0;
        Integer id2 = 0;
        if (userId != null && userId != "") {
            try {
                id = Integer.parseInt(userId.trim());
            } catch (Exception e) {
                return BaseRespVo.invalidParameter("无效参数");
            }
        }
        if (valueId != null && valueId != "") {
            try {
                id2 = Integer.parseInt(valueId.trim());
            } catch (Exception e) {
                return BaseRespVo.invalidParameter("无效参数");
            }
        }
        CommonData<MarketCollect> data = marketCollectService.query(id, id2, info);
        return BaseRespVo.ok(data);

    }
}

/**
 * 用户管理-收货地址
 *
 * @author 86157
 * @since 2022/06/25 22:11
 */